package attori.attuatori;

import gui.houseeditor.Stanza;
import sde.actor.Actor;
import sde.actor.Message;

public class AttuatoreLuce extends Actor implements AttuatoreLuceIF {
	private Stanza stanza;

	public static final byte CREATED = 0, OFF = 1, ON = 2;

	public AttuatoreLuce() {
		become(CREATED);
	}

	@Override
	protected void handler(Message m) {
		switch (currentStatus()) {
		case CREATED:
			if (m instanceof Init) {
				this.stanza = ((Init) m).stanza;
				become(OFF);
			}
			break;
		case OFF:
			if (m instanceof ToOpen) {
				stanza.accendiLuce();
				become(ON);
			}
			break;
		case ON:
			if (m instanceof AttuatoreLuceIF.ToClose) {

				if (m instanceof ToClose) {
					stanza.spegniLuce();
					become(OFF);
				}
				break;
			}
		}

	}
}